package org.hawk.gwt.ppc.reflect.lang;

import org.hawk.gwt.ppc.reflect.lang.mock.Mock2;

import junit.framework.TestCase;

public class ArrayClassDelegateTestCase extends TestCase {
	protected void setUp() throws Exception {
		ReflectionTestHelper.initialize();
	}

	public void testForName() throws ClassNotFoundException {
		ClassDelegate<?> cls = ClassDelegate.forName(Object[].class.getName());
		assertTrue(cls.isArray());
		assertEquals(ClassDelegate.forClass(Object.class),
				cls.getComponentType());

		cls = ClassDelegate.forName(Mock2[].class.getName());
		assertTrue(cls.isArray());
		assertEquals(ClassDelegate.forClass(Mock2.class),
				cls.getComponentType());
	}

	public void testForNamePrimitive() throws ClassNotFoundException {
		ClassDelegate<?> cls = ClassDelegate.forName("[Z");
		assertTrue(cls.isArray());
		assertEquals(ClassDelegate.forName(boolean.class.getName()),
				cls.getComponentType());
		
		cls = ClassDelegate.forName("[[I");
		assertTrue(cls.isArray());
		assertEquals(ClassDelegate.forName(int.class.getName()),
				cls.getComponentType());
	}
}
